function [d1] = comparePhase(s_2dpsk)
    
    n = length(s_2dpsk);
    d1 = zeros(1,n);
    
    count = 1;
    for i = 1 : n
        if(mod(i,8) == 1 && i ~= 1)
            count = count+1;
        end
        if (i == 5)
            if (s_2dpsk(i) == 1)
                d1(count) = 0;
            else
                d1(count) = 1;
            end
        else
            if (mod(i,8) == 5)
                if (s_2dpsk(i-8) * s_2dpsk(i) == 1)
                    d1(count) = 0;
                else
                    d1(count) = 1;
                end
            end
        end
    end
end

